<?
/* @author Udo Schroeter <udo.schroeter@gmail.com>
 * @license dual license: LGPL / commercial use license
 */ 

$noiseCoords = explode(':', $this->zoneStats['noise.map']);
$noiseDist = $this->model->getDistance($noiseCoords[0], $noiseCoords[1], $this->mstats['xpos'], $this->mstats['ypos']);
$this->model->mstats = $this->mstats;
if (isset($this->zoneStats['noise.'.$noiseDist]))
  print($this->zoneStats['noise.'.$noiseDist].'<br/>');
?><table width="50%" align="center">
  <tr>
    <td></td>
    <td><input type="button" value="N" <? if (!$this->model->canGoToRelative(0, -1)) print('style="background: gray;"'); ?> 
      onclick="document.location.replace('<?= actionUrl('index', 'game', 'move=n') ?>');"/></td>
    <td></td>
  </tr>
  <tr>
    <td><input type="button" value="W" <? if (!$this->model->canGoToRelative(-1, 0)) print('style="background: gray;"'); ?> 
      onclick="document.location.replace('<?= actionUrl('index', 'game', 'move=w') ?>');"/></td>
    <td></td>
    <td><input type="button" value="E" <? if (!$this->model->canGoToRelative(1, 0)) print('style="background: gray;"'); ?> 
      onclick="document.location.replace('<?= actionUrl('index', 'game', 'move=e') ?>');"/></td>
  </tr>
  <tr>
    <td></td>
    <td><input type="button" value="S" <? if (!$this->model->canGoToRelative(0, 1)) print('style="background: gray;"'); ?> 
      onclick="document.location.replace('<?= actionUrl('index', 'game', 'move=s') ?>');"/></td>
    <td></td>
  </tr>
</table><br/><?
foreach(@explode(',', $this->mstats['loclist']) as $cloc)
{
  $locText = $this->zoneStats[$cloc.'.text'];
  $locTitle = CutSegment(':', $locText);
  $buttonText = getDefault($this->zoneStats[$cloc.'.button'], 'Move');
  $locType = getDefault($this->zoneStats[$cloc.'.type'], 'info');
  switch($locType)
  {
    case('info'): {
      print('<b>'.$this->zoneStats[$cloc.'.text'].'</b><br/>');
      break;
    } 
    case('zone'): {
      ?><h4><?= $locTitle ?></h4><div><?= nl2br($locText) ?></div>
      <div align="right"
        style="padding-top: 3px;">
        <a href="<?= actionUrl('mapmove', 'game', 'id='.$cloc) ?>" class="linkbutton"><?= $buttonText ?></a></div><?
      break;
    }
    case('action'): {
      $act = DB_GetDataset('actions', substr($cloc, 1));
      $actionStats = TextToStringlist($act['a_stats']);
      $buttonText = getDefault($actionStats['button'], $buttonText);
      ?><h4><?= $act['a_name'] ?></h4><div><?= nl2br($act['a_intro']) ?></div>
      <div align="right" style="padding-top: 3px;"><?
      if($this->character->getCharacterStat('AP') >= $act['a_cost'])
      {
      ?>
      
        <a href="<?= actionUrl('act', 'game', 'id='.$act['a_key']) ?>" class="linkbutton"><?= $buttonText ?></a><?
      }
      else
        print('<b style="color: gray">you need '.$act['a_cost'].' AP for this</b>');
      ?></div><?
      break;
    }
  }
}
?><br/>
<?
if ($this->model->mapMessage != '')
    print('<div class="banner" align="center">'.$this->model->mapMessage.'</div>');
  
?>
